package thread;

public class ThreadDemo12 {
    private static int count = 0;
    public static void main(String[] args) throws InterruptedException {
        Object locked = new Object();
        Thread t = new Thread(() -> {

           for(int i = 0; i <= 1_0000; i++){
                synchronized (locked){
                     count++;
                }
           }
        });
        Thread tt = new Thread(() -> {

            for(int i = 0; i <= 1_0000; i++){
                synchronized (locked){
                    count++;
                }
            }

        });
        t.start();
        tt.start();

        t.join();
        tt.join();

        System.out.println("count的值为:" + count);
    }
}